package com.takeshequ.main;

import android.os.Bundle;
import android.view.KeyEvent;

import com.korovyansk.android.slideout.SlideoutHelper;
import com.takeshequ.BasicFragmentActivity;
import com.takeshequ.R;
import com.takeshequ.SMApplication;

public class MenuActivity extends BasicFragmentActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mSlideoutHelper = new SlideoutHelper(this);
		mSlideoutHelper.activate();
		getSupportFragmentManager()
				.beginTransaction()
				.add(R.id.slideout_placeholder,
						MenuFragment.newInstance(
								this,
								((SMApplication) this.getApplication()).viewPager),
						"menu").commit();
		mSlideoutHelper.open();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			mSlideoutHelper.close();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	public SlideoutHelper getSlideoutHelper() {
		return mSlideoutHelper;
	}

	private SlideoutHelper mSlideoutHelper;

}
